<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>已过期结算订单</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css" />
		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../js/mobile-detect.min.js"></script>
		<script type="text/javascript" src="../js/config.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<style type="text/css">
			.mui-media-body {
				position: relative;
			}

			.logo {
				margin-top: 30px;
			}

			.go_jiesuan {
				position: absolute;
				right: 10px;
				top: 50%;
				margin-top: -8px;
				font-size: 14px;
				color: green;
			}

			.mui-table-view-cell {
				padding: 10px 0 !important;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">已过期结算订单</h1>
		</header>
		<!--下拉刷新容器-->
		<div class="mui-content">
			<div id="pullrefresh">
				<ul class="mui-table-view mui-table-view-chevron" id="list">
					<script type="text/html" id="model">
						{{if status=="success"}}
						{{each data as value i}}
						<li class="mui-table-view-cell" data-orderNum="{{value.out_order_no}}" data-authNo="{{value.auth_no}}">
							<img class="mui-media-object mui-pull-left logo" src="../img/{{value.pay_type}}.png" style="padding: 10px;">
							<div class="mui-media-body">
								<p><label>消费时间：</label>{{value.created_at}}</p>
								<p><label>消费账户：</label>{{value.payer_logon_id}}</p>
								<p><label>交易订单：</label>{{value.out_order_no}}</p>
								<p><label>预授权金额：</label><span style="color:red;">{{value.amount}}</span>元</p>
								<p class="mui-ellipsis"><label>备注信息：</label>{{value.fu_remark}}</p>
							</div>
						</li>
						{{/each}}
						{{/if}}
					</script>
				</ul>
			</div>
		</div>
		<script type="text/javascript" src="../js/template-web.js"></script>
		<script>
						mui.plusReady(function(){
			// 				var count = 1;  //页码
			// 				var page_number=8;  //每页的数据数 
			// 				var ws = plus.webview.currentWebview();
							mui.init({
								pullRefresh: {
									container: '#pullrefresh',
									down: {
										style: 'circle',
										callback: pulldownRefresh
									},
									up: {
										auto: true,
										contentrefresh: '正在加载...',
										callback: pullupRefresh
									}
								}
							});
							var ws = plus.webview.currentWebview();
							var pay_status=ws.pay_status?ws.pay_status:"";
							var count = 1;
							var page_number = 10;
							//上拉数据渲染
							function pullupRefresh() {
								console.log('上拉加载');
								console.log("+page_number+","+pay_status+");
								require(weburl + getOverTimeOrders, "json", "post", {
									token: localStorage.getItem("token"),
									page: count++,
									limit: page_number,
									pay_status: pay_status
								}, function(response) {
									console.log(count)
									console.log(JSON.stringify(response));
									console.log(response.data.length);
									if((response.status == "error")||(response.data.length==0)) {
										//参数为true代表没有更多数据了。
										mui('#pullrefresh').pullRefresh().endPullup(true);
										// this.endPullupToRefresh(true);
										mui.toast(response.msg, {
											duration: 'long',
											type: 'div'
										})
										return false;
									}
									
									if(response.data.length < page_number) {
										mui('#pullrefresh').pullRefresh().endPullup(true);
										// this.endPullupToRefresh(true);
										upAddData(response);
										return false;
									}
									
									setTimeout(function() {
										mui('#pullrefresh').pullRefresh().endPullup(false);//参数为true代表没有更多数据了。
										// this.endPullupToRefresh(false);
										upAddData(response);
									}, 1500);
								}, function(error) {
									mui.toast('网络错误', {
										duration: 'long',
										type: 'div'
									})
								})
								
							}
							/**
							* 下拉刷新具体业务实现
							*/
							
							//数据渲染
							//上拉数据渲染
							function upAddData(resData) {
								var str = template("model", resData);
								$("#list").append(str);
							}
							// 下拉
							function downAddData(resData) {
								//清空记录
								$("#list").html("");
								var str = template("model", resData);
								$("#list").html(str);
							}
							function pulldownRefresh() {
								console.log('下拉刷新');
								count = 1;
								require(weburl + getOverTimeOrders, "json", "post", {
									token: localStorage.getItem("token"),
									page: count++,
									limit: page_number,
									pay_status: ws.pay_status
								}, function(response) {
									console.log(JSON.stringify(response));
									setTimeout(function() {
										downAddData(response);
										mui('#pullrefresh').pullRefresh().endPulldown();
										// 重置上拉加载
										mui('#pullrefresh').pullRefresh().refresh(true);
									}, 1500);
								}, function(error) {
									mui.toast('网络错误', {
										duration: 'long',
										type: 'div'
									})
								})
								
							}
							
							//点击对应订单跳到详情页
							mui("body").on("tap","#list .mui-table-view-cell",function(){
								console.log(1);
								mui.openWindow({
									url:"depositDetail.html",
									id:"depositDetail.html",
									extras:{
										authNo:$(this).attr("data-authNo"),
										orderNum:$(this).attr("data-orderNum"),
										fromTo: 'overTime'
									}
								})
							})
						})

		</script>
	</body>

</html>
